package com.hanoi.wiki.model.json;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.codehaus.jackson.map.annotate.JsonSerialize;

import com.hanoi.wiki.common.DateSerializer;
import com.hanoi.wiki.model.Blocks;
import com.hanoi.wiki.model.Coordinates;

public class CoordinatesJson extends BaseJsonObject implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private int id;
	private float longtitue;
	private float latitue;
	private float range;
	private Date updatedTime;
	private String note;
	private List<Integer> blocks;
	
	public CoordinatesJson() {
		blocks = new ArrayList<Integer>();
	}
	
	public CoordinatesJson(Coordinates coordinates) {
		if(coordinates != null) {
			this.id = coordinates.getId();
			this.longtitue = coordinates.getLongtitue();
			this.latitue = coordinates.getLatitue();
			this.range = coordinates.getRange();
			this.updatedTime = coordinates.getUpdatedTime();
			this.note = coordinates.getNote();
			
			for(Blocks block : coordinates.getBlocks()) {
				if(block !=null) {
					this.blocks.add(block.getId());
				}
			}
		}
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public float getLongtitue() {
		return longtitue;
	}

	public void setLongtitue(float longtitue) {
		this.longtitue = longtitue;
	}

	public float getLatitue() {
		return latitue;
	}

	public void setLatitue(float latitue) {
		this.latitue = latitue;
	}

	public float getRange() {
		return range;
	}

	public void setRange(float range) {
		this.range = range;
	}
	
	@JsonSerialize(using=DateSerializer.class)
	public Date getUpdatedTime() {
		return updatedTime;
	}

	public void setUpdatedTime(Date updatedTime) {
		this.updatedTime = updatedTime;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public List<Integer> getBlocks() {
		return blocks;
	}

	public void setBlocks(List<Integer> blocks) {
		this.blocks = blocks;
	}
	
	
}
